<?php
namespace app\common\model;
/**
 * Created by PhpStorm.
 * User: junyv
 * Date: 2016/9/18
 * Time: 10:36
 */
class Answer extends \think\Model
{
    protected $autoWriteTimestamp = true;
    protected $updateTime = false;
    public function Ask(){
        return $this->hasOne('ask','id','ask_id',[],'left')->field('title');
    }
    public function user(){
        return $this->hasOne('user','id','user_id',[],'left')->field('nickname,buy_phone,headimgurl');
    }
    protected function setContentAttr($value){
        $badword = cache('badword');
        if($badword){
            $tmp = [];
            foreach($badword as $v){
                $tmp[$v['word']] = $v['level']==2?'':$v['replace_word'];
            }
            if($tmp){
                return strtr($value,$tmp);
            }
        }
        return $value;
    }
}